﻿// ******************************************************************
//        /\ /|       @file       Feishu1StLevelApprovers.cs
//        \ V/        @brief
//        | "")       @author     向征, xiangzheng@shjinjia.com.cn
//        /  |
//       /  \\        @Modified   2023-11-10
//     *(__\_\        @Copyright  Copyright (c) 2023, 向征
// ******************************************************************
// 

using System.Collections.Generic;
using System.Threading.Tasks;
using Jinjia.Approve.IRepository;
using Jinjia.Approve.IService.JJFlow.Approvers;

namespace Jinjia.Approve.Service.JJFlow.Approvers
{
    /// <summary>
    /// 获取飞书一级领导审批、二级领导审批
    /// </summary>
    public class Feishu1StLevelApprovers : IJJApprovers
    {
        private readonly IErpaUserRepository _erpaUserRepository;

        public Feishu1StLevelApprovers(IErpaUserRepository erpaUserRepository)
        {
            _erpaUserRepository = erpaUserRepository;
        }
        
        public async Task<List<int>> GetInstanceNodeEmpInfo(string biz_order_id, int start_user = 0, string depart_id = "0", Dictionary<string, string> dic = null)
        {
            var userParentOrg = _erpaUserRepository.GetUserParentOrg(start_user, depart_id);

            var result = userParentOrg.LeaderUserId == start_user ? // 此人是部门领导再往上找一级
                new List<int> { userParentOrg.ParentLeaderUserId } : new List<int> { userParentOrg.LeaderUserId };

            return await Task.FromResult(result);
        }
    }
}